import { IsBoolean, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

/** 新建权限（菜单）dto 验证 */
export class CreatePermissionDto {
  @ApiProperty({ description: '权限code' })
  @IsString()
  @IsNotEmpty({ message: '权限code不能为空' })
  code: string;

  @ApiProperty({ description: '组件路径(相对于views下的路径)' })
  @IsString()
  @IsNotEmpty({ message: '组件路径不能为空' })
  component: string;

  @ApiPropertyOptional({ description: '权限描述' })
  @IsString()
  @IsOptional()
  description: string;

  @ApiProperty({ description: '是否启用' })
  @IsBoolean()
  @IsNotEmpty({ message: '是否启用不能为空' })
  enable: boolean;

  @ApiPropertyOptional({ description: 'icon图标' })
  @IsString()
  @IsOptional()
  icon: string;

  @ApiProperty({ description: '菜单名称' })
  @IsString()
  @IsNotEmpty({ message: '菜单名称不能为空' })
  name: string;

  //   @ApiProperty({description:'排序'})
  //   @IsString()
  //   order: number;

  @ApiPropertyOptional({ description: '父节点id' })
  @IsNumber()
  @IsOptional()
  parentId?: number;

  @ApiProperty({ description: '菜单路由' })
  @IsString()
  @IsNotEmpty({ message: '菜单路由不能为空' })
  path: string;

  @ApiPropertyOptional({ description: '重定向地址' })
  @IsString()
  @IsOptional()
  redirect?: string;

  @ApiProperty({ description: '是否展示' })
  @IsBoolean()
  @IsNotEmpty({ message: '是否展示不能为空' })
  show: boolean;

  @ApiProperty({ description: '国际化翻译' })
  @IsString()
  @IsNotEmpty({ message: '国际化翻译不能为空' })
  translation: string;

  //   widgets?: [];
}
